﻿@model AppStore.Domain.Entities.Application

@{
    ViewBag.Title = "Details";
}

<div id="details">
<h2>@Model.name</h2>
<p>Opis:</p>
<p>@Model.description</p>
<p>Cena: $@Model.price</p>

<div>
    <div id="rating">
        @if(Double.IsNaN(ViewBag.Average)) 
        {
            <p>Ocena: Brak ocen</p>
        }
        else
        {
            <p>Ocena: @ViewBag.Average </p>
        }
    </div>
    <div id="cart">
        @using (Html.BeginForm("AddToCart", "Cart"))
        {
        @Html.Hidden("applicationId",Model.applicationId)
        @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
        <input type="submit" value="Dodaj do koszyka" class="button_add"/>
        }
    </div>
</div>
<div id="comments">
<h3>Oceń i dodaj komentarz</h3>

<!-- Star rating !!! -->
<div class="rateit"></div>

@using(Html.BeginForm("AddComment","Application")){
@Html.Hidden("applicationId",Model.applicationId)
@Html.Hidden("returnUrl", Request.Url.PathAndQuery)
@Html.TextBox("commentText", "",new { @class = "comment_text"})
<input type="submit" value="Dodaj"/>
}

<h3>Komentarze</h3>
@foreach (var item in ViewBag.Comments)
{
    <p>
        Ocena: @item.rating 
        Komentarz: @item.comment
    </p>
}
</div> <!-- End comments -->
</div> <!-- End details -->